package rowset;

import java.sql.SQLException;

import javax.sql.rowset.JdbcRowSet;

import com.sun.rowset.JdbcRowSetImpl;

public class ConnectedRowset {
	public static void main(String[] args) {

		try {
			JdbcRowSet jdbcRS = new JdbcRowSetImpl();

			Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");

			jdbcRS.setUrl("jdbc:sqlserver://bdk-pc;databaseName=demo;");
			jdbcRS.setUsername("sa");
			jdbcRS.setPassword("123456");

			jdbcRS.setCommand("SELECT * FROM SINHVIEN");

			jdbcRS.execute();

			while (jdbcRS.next()) {
				System.out.println(jdbcRS.getString(1));
			}
		} catch (ClassNotFoundException ex) {
			ex.printStackTrace();
		} catch (SQLException ex) {
			ex.printStackTrace();
		}
	}

}
